﻿using System;
using Hematology.Tools.Storage;

namespace Hematology.UserSite
{
	public class Global : System.Web.HttpApplication
	{

		protected void Application_Start(object sender, EventArgs e)
		{

		}

		protected void Session_Start(object sender, EventArgs e)
		{

		}

		protected void Application_BeginRequest(object sender, EventArgs e)
		{

		}

		protected void Application_AuthenticateRequest(object sender, EventArgs e)
		{

		}

		protected void Application_Error(object sender, EventArgs e)
		{
			try
			{
				Exception lastError = Server.GetLastError();

				if (lastError != null)
				{
					SessionHelper.LastException = lastError.InnerException;
				}

				Server.ClearError();

				Response.Redirect("/Error.aspx");
			}
			catch (Exception)
			{
				Response.Write("К сожалению произошла критическая ошибка. Нажмите кнопку 'Назад' в браузере и попробуйте ещё раз. ");
			}
		}

		protected void Session_End(object sender, EventArgs e)
		{

		}

		protected void Application_End(object sender, EventArgs e)
		{

		}
	}
}